//
// xmldefn.h
// libprotea
// Tools Library for the Protea Project / XML Protea DOM definition
// Copyright (C) 2003, 2004, 2005 eXegeSys, Inc.
// Copyright (C) 2008 Bruce A. James
//
// This program is part of the Protea Project.
//
// The Protea Project is free software; you can redistribute it and/or modify it 
// under the terms of the GNU General Public License as published by the 
// Free Software Foundation, either version 3 of the License, or (at your 
// option) any later version.
//
// The Protea Project is distributed in the hope that it will be useful, but 
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
// for more details.
// 
// You should have received a copy of the GNU General Public License along 
// with this program.  If not, see <http://www.gnu.org/licenses/>.
// 
// Please send correspondence to:
// 
// theproteaproject@gmail.com
//

// xmldefn.h
//
// Includes the Protea DOM classes

#ifndef __PROTEA_XMLDEFN_H__
#define __PROTEA_XMLDEFN_H__
#include <stdlib.h>
#include <string.h>
#include <assert.h>

// XML Property Tag
class __EXPORT XCXML_Property
{
public:
	// Constructor
	XCXML_Property();
	// Destructor
	~XCXML_Property();

	// Property Name
	char* Name;
	// Property Value
	char* Value;
	// Next Property in Property List
	XCXML_Property* next;
};

// XML Script Tag
class __EXPORT XCXML_Script
{
public:
	// Constructor
	XCXML_Script();
	// Destructor
	~XCXML_Script();

	// Script Type
	char* Type;
	// Script Event or Function Name
	char* Event;
	// Body of the Script
	char* Value;
	// Next Script in Script List
	XCXML_Script* next;
};

// XML Trigger Tag
class __EXPORT XCXML_Trigger
{
public:
	// Constructor
	XCXML_Trigger();
	// Destructor
	~XCXML_Trigger();

	// Trigger Key (0=Enter, 1-12=F1-F12)
	char* Key;
	// Trigger Type
	char* Type;
	// Trigger Value
	char* Value;
	// Next Trigger in Trigger List
	XCXML_Trigger* next;
};

// XML Object Tag
class __EXPORT XCXML_Object
{
public:
	// Constructor
	XCXML_Object();
	// Destructor
	~XCXML_Object();

	// Add a Property to the Property List
	XCXML_Property* AddProperty();
	// Find and return a Property from the Property List
	XCXML_Property* GetProperty( char* Name );
	// Add a Script to the Script List
	XCXML_Script* AddScript();
	// Find and return a Script from the Script List
	XCXML_Script* GetScript( char* Event );

	// Object Number
	char* Number;
	// Object Name
	char* Name;
	// Propert List for this Object
	XCXML_Property* PropertyList;
	// Script List for this Object
	XCXML_Script* ScriptList;
	// Next Object in Object List
	XCXML_Object* next;
};

// XML Form Tag
class __EXPORT XCXML_Form
{
public:
	// Constructor
	XCXML_Form();
	// Destructor
	~XCXML_Form();

	// Add a Property to the Property List
	XCXML_Property* AddProperty();
	// Find and return a Property from the Property List
	XCXML_Property* GetProperty( char* Name );
	// Add a Script to the Script List
	XCXML_Script* AddScript();
	// Find and return a Script from the Script List
	XCXML_Script* GetScript( char* Type, char* Event );
	// Add a Trigger to the Trigger List
	XCXML_Trigger* AddTrigger();
	// Find and return a Trigger from the Trigger List
	XCXML_Trigger* GetTrigger( char* Key );
	// Add an Object to the Object List
	XCXML_Object* AddObject();
	// Find and return an Object from the Trigger List by Name
	XCXML_Object* GetObject( char* Name );
	// Find and return an Object from the Trigger List by Number
	XCXML_Object* GetObject( long Number );

	// Form Number
	char* Number;
	// Form Name
	char* Name;
	// Property List for this Form
	XCXML_Property* PropertyList;
	// Script List for this Form
	XCXML_Script* ScriptList;
	// Trigger List for this Form
	XCXML_Trigger* TriggerList;
	// Object List for this Form
	XCXML_Object* ObjectList;
	// Next Form in Form List
	XCXML_Form* next;
};

// XML Message Tag
class __EXPORT XCXML_Message
{
public:
	// Constructor
	XCXML_Message();
	// Destructor
	~XCXML_Message();

	// Message Number
	char* Number;
	// Message Severity
	char* Severity;
	// Offending Field Number
	char* Field;
	// Buffer Order Number
	char* Order;
	// Required Message
	char* Required;
	// Message Text
	char* Value;
	// Next Message in a MessageList
	XCXML_Message* next;
};

// XML Field Tag
class __EXPORT XCXML_Field
{
public:
	// Constructor
	XCXML_Field();
	// Destructor
	~XCXML_Field();

	// Field Number
	char* Number;
	// Field Name
	char* Name;
	// Field Value
	char* Value;
	// Next Field in a FieldList (Buffer)
	XCXML_Field* next;
};

// XML Buffer Tag
class __EXPORT XCXML_Buffer
{
public:
	// Constructor
	XCXML_Buffer();
	// Destructor
	~XCXML_Buffer();

	// Add a Field to this Buffer
	XCXML_Field* AddField();
	// Find and return a Field by Number
	XCXML_Field* GetField( long Number );
	// Find and return a Field by Name
	XCXML_Field* GetField( char* Name );

	// Buffer Format Number
	char* Number;
	// Buffer Format Name
	char* Name;
	// Buffer Type (Header or Detail)
	char* Type;
	// Buffer resolution required
	char* Required;
	// Field List for this buffer
	XCXML_Field* FieldList;
	// Next Buffer in BufferList
	XCXML_Buffer* next;
};

// XML Transaction Tag
class __EXPORT XCXML_Transaction
{
public:
	// Constructor
	XCXML_Transaction();
	// Destructor
	~XCXML_Transaction();

	// Add a Buffer to this Transaction
	XCXML_Buffer* AddBuffer();
	// Find and return a Buffer by Number
	XCXML_Buffer* GetBuffer( long Number );
	// Find and return a Buffer by Name
	XCXML_Buffer* GetBuffer( char* Name );
	// Add a Message to this Transaction
	XCXML_Message* AddMessage();
	// Find and return a Message by Number
	XCXML_Message* GetMessage( long Number );

	// Transaction Format Number
	char* Number;
	// Transaction Format Name
	char* Name;
	// Transaction Success Flag
	char* Success;
	// Transaction Description for testing
	char* Description;
	// Transaction User Name
	char* UserName;
	// Transaction Password
	char* Password;
	// Transaction Result Ignored for testing
	char* Ignore;
	// Super Transaction ID Number
	char* Super;
	// Super Transaction Action
	char* Action;
	// Phase of Transaction (0=none,1+)
	char* Phase;
	// Buffer List for this Transaction
	XCXML_Buffer* BufferList;
	// Message List for this Transaction
	XCXML_Message* MessageList;
	// Next Transaction in TransactionList
	XCXML_Transaction* next;
};

// XML TransactionList Tag
class __EXPORT XCXML_TransactionList
{
public:
	// Constructor
	XCXML_TransactionList();
	// Destructor
	~XCXML_TransactionList();
	
	// Add a Transaction to this Transaction List
	XCXML_Transaction* AddTransaction();

	// Application Number for this Transaction List
	char* ApplNumber;
	// Type of Transaction List (Normal or Super)
	char* Type;
	// Default UserName for all Transactions
	char* UserName;
	// Default Password for all Transactions
	char* Password;
	// List of Transactions 
	XCXML_Transaction* Transactions;
	// Next TransactionList in the Protea Tag
	XCXML_TransactionList* next;
};

// XML Protea Root Tag
class __EXPORT XCXML_Protea
{
public:
	// Constructor
	XCXML_Protea();
	// Destructor
	~XCXML_Protea();

	// Add a Form to the Form List
	XCXML_Form* AddForm();
	// Find and return a Form from the Form List by Name
	XCXML_Form* GetForm( char* Name );
	// Find and return a Form from the Form List by Number
	XCXML_Form* GetForm( long Number );
	// Add a TransactionList
	XCXML_TransactionList* AddTransactionList();

	// Protea Version Number
	char* Version;
	// Application Number
	char* ApplNumber;
	// Terminal (I or UI) Type
	char* TermType;
	// List of Forms for Protea
	XCXML_Form* FormList;
	// List of Transactions for Protea
	XCXML_TransactionList* TransactionListList;
};

#endif
